
#include <stdio.h>	  
#include "appControl.h"
#include "baseData.h"
#include "gpio.h"
#include "led.h"
#include "diode.h"
  
#include "app_task.h"
#include "communicatUart3Rx.h"
static uint16_t dist=0;
uint8_t vi5300IsExistFlag=0;

void tofControl(void)
{
	static uint8_t tmptimes=0;
 	VI5300_Get_Measure_Data(&dist);
	
	if(distance.confidence<=20)
	{
		if(tmptimes++>25)
		{
			tmptimes=0xf0;
			dist=0xff;
		}
	}
	else
	{
		tmptimes=0;
	}
 
	if(dist>255)
	{
		dist=0xff;
	}
 	DeviceInfo.height=(uint8_t)dist;
}

//READ_SHAKE默认是0，有金属的时候才是1
void shakeControl(float dt)
{
	static uint8_t flagtmp,shakenum;
	static float sumdt;
	if(READ_SHAKE)
	{
		if(g_DetectTimeOpen==1)
		{
			sumdt+=dt;
			printf("take time=%f\r\n",sumdt);
			//xTimerStart((TimerHandle_t)Timer1Timer_Handler,(TickType_t)portMAX_DELAY);
		}
		if(existenceFlag==0)
		{
			DIODE_L;//on
		}
		if(1==flagtmp)
		{
			flagtmp=0;
			shakenum++;
			DeviceInfo.shake=shakenum;
		}
	}
	else
	{
		if(g_DetectTimeOpen==1)
		{
			sumdt=0;
			//timer1_num=0;
			//xTimerStop((TimerHandle_t)Timer1Timer_Handler,(TickType_t)portMAX_DELAY);
		}
		if(existenceFlag==0)
		{
			DIODE_H;//off
		}
		flagtmp=1;
	}	
}



